<template>
  <el-card class="allanxu-container">
    <el-table
      :data="allAnxuList"
      type="border-card"
      style="width: 100%"
      height="700"
      v-loading="loading"
      :element-loading-text="loadingText"
    >
      <el-table-column prop="cname" label="公司名称"> </el-table-column>
      <el-table-column prop="date" label="到期时间"> </el-table-column>
      <el-table-column prop="lperson" label="公司法人"></el-table-column>
      <el-table-column fixed="right" label="操作" width="180">
        <template slot-scope="scope">
          <el-button
            @click="$router.push(`/enterprise/detail/${scope.row.cname}`)"
            type="text"
            size="small"
            >查看</el-button
          >
        </template>
      </el-table-column>
      <template slot="empty">
        <el-empty :image-size="200" description="暂无全部安许"></el-empty>
      </template>
    </el-table>
    <!-- 分页组件 -->
    <div style="height: 60px; margin-top: 25px">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page"
        :page-sizes="[15, 30, 40]"
        :page-size="page_size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </el-card>
</template>

<script>
import { getAllAnxuListApi } from '@/api/anxu'
export default {
  name: 'allanxu-page',
  data () {
    return {
      page: 1,
      page_size: 15,
      total: 0,
      allAnxuList: [],
      company_id: 0,
      loading: false,
      loadingText: ''
    }
  },
  created () {
    this.roleid = localStorage.getItem('crm-roleid')
    this.getAllAnxuList()
  },
  methods: {
    // 获取 全部安许 列表
    async getAllAnxuList () {
      this.loading = true
      this.loadingText = '数据正在加载中!'
      const { data: res } = await getAllAnxuListApi(this.page, this.page_size)
      // console.log('获取 全部安许 列表', res)
      this.allAnxuList = [...res.data.lists]
      // console.log('全部安许', this.allAnxuList)
      this.total = res.data.anxu_num
      this.loading = false
      this.loadingText = ''
    },
    // 切换第几页
    handleCurrentChange (val) {
      this.page = val
      this.getAllAnxuList()
    },
    // 手动更改页码
    handleSizeChange (val) {
      this.page_size = val
      this.getAllAnxuList()
    }
  },
  watch: {}
}
</script>

<style lang="scss" scoped>
.allanxu-container {
  box-sizing: border-box;
  height: 835px;
  padding: 25px 40px 0px;
}
</style>
